package com.liuyongyi.livepush.Activity;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.PixelFormat;
import android.hardware.display.DisplayManager;
import android.hardware.display.VirtualDisplay;
import android.media.Image;
import android.media.ImageReader;
import android.media.MediaRecorder;
import android.media.projection.MediaProjection;
import android.media.projection.MediaProjectionManager;
import android.os.Build;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.SurfaceView;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ToggleButton;

import com.liuyongyi.livepush.R;
import com.liuyongyi.livepush.base.BaseActivity;
import com.liuyongyi.livepush.camerapush.LivePusher;
import com.liuyongyi.livepush.utils.LogUtils;

import java.io.IOException;
import java.nio.ByteBuffer;

public class CameraPusherActivity extends BaseActivity {
    private SurfaceView camerasurface;
    private LivePusher livePusher;
    private static final String URL ="";
    private Button startpush;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_camera_pusher);
        initView();

    }
    public  void initView(){
        camerasurface = findViewById(R.id.camerasurface);
        //相机图像的预览
        livePusher = new LivePusher(camerasurface.getHolder());
        startpush = findViewById(R.id.startpush);
    }
    public void onClick(View view){
        switch (view.getId()){
            case R.id.switchcamera:
                //切换摄像头
                livePusher.switchCamera();
                break;
            case R.id.startpush:
                //
                if(startpush.getText().toString().trim().equals("开始")){
                    livePusher.startPusher(URL);
                    startpush.setText("结束直播");
                }else {
                    livePusher.stopPusher();
                    startpush.setText("开始直播");
                }

                break;
        }
    }
}
